/*
 * @Author: yangdingyuan yangdingyuan@bjjy.com
 * @Date: 2022-10-08 15:21:28
 * @LastEditors: yangdingyuan
 * @LastEditTime: 2022-10-08 15:29:46
 * @Description: 模拟已被v6路由包废弃的withRouter的hoc函数
 */
import React from 'react';
import { useLocation, useNavigate, useParams } from 'react-router-dom';

const withRouter = function withRouter(Child) {
    return function (props) {
        const location = useLocation();
        const navigate = useNavigate();
        const params = useParams();
        return (
            <Child
                {...props}
                navigate={navigate}
                params={params}
                location={location}
            />
        );
    };
};

export default withRouter;
